-
-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/username edit #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The bad part about code is that it does exactly what you tell it to!
When not set in an environment variable, `COOKIE_EXPIRES_IN` will default to `60 * 60 * 24 * 7` = 604,800s = 7 days, since the `Max-Age` cookie attribute is specified in seconds: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#max-agenumber However, the `res.cookie` function takes the `maxAge` **in milliseconds**. which means that the previous amount of seconds actually meant *604.8 seconds* ~= 10 minutes. Oof.
…nto feature/username-edit
About the profanity check I was searching about it and I saw some node libraries like:
I recalled Steam's profanity filter, was leaked I have a fork of it, here steam-profanity-filter it is a good profanity filter, it supports a lot of languages, but is only a regex like a word list. |
We might get away without one for now, as song titles/descriptions have no profanity check either. Manual moderation may be enough for now until we can invest in better automated checks. It's also far from a trivial problem, especially when multiple languages are involved. I took a look at some of the profanity word lists you sent for the Portuguese language and they're nowhere near as exhaustive as they could be – I could think of five words that weren't covered in the list in a not-so-long timespan. 😅 (For instance, there was once a problem with users not being able to rename an item to "Stone Hoe" in Minecraft Bedrock Edition, or "computador" being replaced with "com****dor", see Scunthorpe problem.) |
@Bentroen I merged your front-end changes from feat/username-change. I will take a look at the failing test to merge this branch |
Thanks for merging! Happy New Year! 🥂✨
Usernames are meant to be used in the URL slug for usernames in a future update, just like YouTube/TikTok user handles (i.e. https://noteblock.world/@Bentroen). I'm pretty sure those platforms restrict the characters that may be there to a small subset to keep the URLs uniform and easily typable. In fact the chosen characters (A-z 0-9 - _ .) are exactly what I recall YouTube uses in their new handles :) There's an additional concern with this: non-ASCII characters cannot be properly encoded in NBS files, and we currently inject the uploader's username into the 'Author' field of the song file. As such, we need the user to provide us an ASCII-safe string to use as their author name, because doing an 'educated guess' using unidecode could have a lot of bad implications, or even be outright offensive. To circumvent this, we may implement a 'Display name' on the user profile that would be displayed in most places across the interface — which could be way less restrictive in terms of the allowed characters. |
This pull request includes adding a feature to update usernames.
User Management Enhancements:
Server-side updates:
UpdateUsernameDto
for validating username updates (server/src/user/user.controller.ts
,server/src/user/user.service.ts
) [1] [2].updateUsername
method inUserController
to handle PATCH requests for updating usernames (server/src/user/user.controller.ts
).updateUsername
andnormalizeUsername
methods inUserService
to handle username updates and normalization respectively (server/src/user/user.service.ts
) [1] [2].normalizeUsername
andupdateUsername
methods inUserService
(server/src/user/user.service.spec.ts
).Client-side updates:
ClientAxios
) with an interceptor to add authorization tokens to requests (web/src/lib/axios/ClientAxios.ts
). In the future, this client will be used for all requests to the server as it will automatically add the authorization token to the request headers.GenericModal
to use TypeScript interfaces for props (web/src/modules/shared/components/client/GenericModal.tsx
) [1] [2].EditUsernameModal
component to allow users to edit their username through a modal interface (web/src/modules/shared/components/layout/EditUsernameModal.tsx
).EditUsernameModal
into theUserMenu
component, allowing users to trigger the modal from their user menu (web/src/modules/shared/components/layout/UserMenu.tsx
) [1] [2] [3].Preview:
In the user menu, users can now click on the pen icon next to their username to open a modal where they can update their username.

The modal allows users to enter a new username and submit the form to update their username. The modal will display any errors that occur during the update process, such as an invalid username or a username that is already taken and throttling limits.

Testing:
On the backend, I have added tests for the
normalizeUsername
andupdateUsername
methods in theUserService
class.I have concerns about whether non-ASCII characters should be allowed in usernames. Currently, they're not allowed, but it would be cool if they were.
And, we don't have a profanity filter for usernames, so we should consider adding one before allowing this feature to be used in production.